package com.mentaleye.dal.dao.mybatis;

import com.mentaleye.dal.dao.CompanyStudentDao;
import com.mentaleye.dal.model.CompanyStudent;
import com.mentaleye.dal.model.CompanyStudentExample;
import com.mentaleye.dal.service.CompanyStudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Rock on 2017/5/19.
 */
@Repository
public class CompanyStudentDaoImpl extends BaseDao implements CompanyStudentDao {

    @Autowired private CompanyStudentMapper companyStudentMapper;

    public boolean insert(CompanyStudent companyStudent){
        return getResultByInt(companyStudentMapper.insertSelective(companyStudent));
    }

    public boolean update(CompanyStudent companyStudent){
        return getResultByInt(companyStudentMapper.updateByPrimaryKeySelective(companyStudent));
    }

    public boolean updateByExample(CompanyStudent companyStudent,CompanyStudentExample example){
        return getResultByInt(companyStudentMapper.updateByExample(companyStudent,example));
    }

    public boolean deleteByExample(CompanyStudentExample example){
        return getResultByInt(companyStudentMapper.deleteByExample(example));
    }

    public List<Map<String, Object>> selectByState(Integer stuState, Integer workState){
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("state",stuState);
        map.put("workState",workState);
        return companyStudentMapper.selectByState(map);
    }

    public Map<String, Object> selectDataByReturnVisitId(Integer returnVisitId){
        return companyStudentMapper.selectDataByReturnVisitId(returnVisitId);
    }

    public List<Map<String, Object>> selectStudentByCompanyId(Integer companyId){
        return companyStudentMapper.selectStudentByCompanyId(companyId);
    }
}
